package com.example.testlib

import java.util.*

// Kotlin 集合使用实例
object CollectionExample {
    val array = Array(5, { it })

    val list = listOf(1, 2, 3, 4, 5)
    val mutableList = mutableListOf(11, 22, 33, 44, 55)

    val list1 = List(5, { it + 1 })

    fun a() {
        array[0] = 100
        array.forEach {
            print(it)
        }
        println()
        list1.forEach {
            print(it)
        }

        val doubled = List(3, { it * 2 })  // 如果你想操作这个集合，应使用 MutableList
        println(doubled)

        val linkedList = LinkedList<String>(listOf("one", "two", "three"))
        linkedList.add("four")

        val arr = Array(4, { it })
        arr[0] = 100
    }
}